//数组拆分I
#include<stdlib.h>>

int cmp(const void* a, const void* b)
{
    return *(int*)a - *(int*)b;
}

int arrayPairSum(int* nums, int numsSize)
{
    qsort(nums,numsSize,sizeof(int),cmp);
    int i = 1;
    int sum = 0;
    for(i = 0; i<numsSize ; i+=2)
        sum+=nums[i];
    return sum;
}

//杨辉三角
/**
 * Return an array of arrays of size *returnSize.
 * The sizes of the arrays are returned as *returnColumnSizes array.
 * Note: Both returned array and *columnSizes array must be malloced, assume caller calls free().
 */
int** generate(int numRows, int* returnSize, int** returnColumnSizes)
{
    int row = 0;
    *returnSize = numRows;
    *returnColumnSizes = (int*)malloc(numRows*sizeof(int));
    int**ans = (int**)malloc(numRows*sizeof(int*));
    for(row = 0; row<numRows ; ++row)
    {
        (*returnColumnSizes)[row] = row + 1;
        ans[row] = (int*)malloc(numRows*sizeof(int));
        for(int j = 0;j<=row;++j)
        {
            if(j==0||j==row)
                ans[j] = 1;
            else
                ans[j] = ans[row-1][j] + ans[row-1][j-1];
        }
    } 
    return ans;
}